<?php
class globalPartialsComponents extends sfComponents
{
    public function executeNav()
    {
        $user = sfContext::getInstance()->getUser();
        $menu =
            GraduaMenu::build()
            ->addItem(null, 'mainMenu.callShowUsers();', 'Users', array('MANAGE_USERS'))
            ->addItem(null, 'mainMenu.callShowRoles();', 'Roles', array('MANAGE_ROLES'))
            ->addItem(null, 'mainMenu.callShowProjects();', 'Projects', array('VIEW_PROJECTS','MANAGE_PROJECTS'));
        if($user->hasAttribute('projectId')) {
            $menu
                ->addItem(null, 'mainMenu.callShowTasks();', 'Tasks', array('VIEW_TASKS','MANAGE_TASKS'))
                ->addItem(null, 'mainMenu.callShowAllTests();', 'Tests', array('VIEW_TESTS','MANAGE_TESTS'))
                ->addItem(null, 'mainMenu.callShowSprints();', 'Sprints', array('VIEW_SPRINTS','MANAGE_SPRINTS'));
        }
        if($user->isAuthenticated()) {
            $menu
                ->addItem(null, 'auth.callLogout();', 'Logout', array());
        }
        $this->navMenuTpl  = partial2Js('globalPartials/nav.jstpl',array(),true);
        $this->menu = $menu->toArray($user->listCredentials());
        $this->name = $user->getAttribute('name');
        $this->projectName = $user->getAttribute('projectName');
        
    }
}
